package com.tywj.panda.home.route

import android.app.Activity
import com.tywj.panda.customer.common.entity.HomeLineDetailsEntity
import com.tywj.panda.home.buy.HomeBuyTicketsActivity
import com.tywj.panda.home.buy.HomeLineDetailsActivity
import com.tywj.panda.home.entity.HomeLineEntity
import com.tywj.lib.core.common.view.BaseFragment
import com.tywj.lib.route.RouteNavigation
import com.tywj.panda.home.entity.NoticeEntity
import com.tywj.panda.home.notice.NoticeDetailsActivity


/**
 * @desc 首页组件Native路由和H5页面地址
 * @author June Yang
 * @date 2020/5/9
 */
object HomeRoute {
    // 首页
    const val HOME = "/home/home"

    //到购买页
    const val HOME_BUY = "/home/buyTickets"

    const val HOME_PAY = "/home/pay"

    // 消息通知界面
    const val NOTICE_LIST = "/home/notice"

    // 消息详情界面
    const val NOTICE_DETAILS = "/home/noticeDetails"

    //选择城市
    const val HOME_SELECTED_CITY = "/home/selectedCity"


    // 通知详情
    const val NOTICE_DETAIL = "/home/noticeDetail"

    //线路详情页
    const val HOME_LINE_DETAILS = "/home/lineDetails"


    // 首页组件服务
    const val HOME_SERVICE = "/home/Homeservice"


    /**
     * 获取首页Fragment
     */
    fun getHomeFragment(activity: Activity): BaseFragment {
        return RouteNavigation(HOME)
            .navigation(activity) as BaseFragment
    }

    /**
     * 到购票页
     * @param selectedTimeIndex 选择的班次时间 位置
     * @param isFromHome 是否从首页进入购票界面
     */
    fun toBuyTickets(
        lineCode: String,
        lineName: String = "",
        selectedTimeIndex: Int = 0,
        startStationPos: Int = 0,
        endStationPos: Int = 0,
        isFromHome: Boolean = false,
        stationsList: ArrayList<HomeLineDetailsEntity.Station> = ArrayList<HomeLineDetailsEntity.Station>()
    ): RouteNavigation {
        return RouteNavigation(HOME_BUY)
            .param(HomeBuyTicketsActivity.PARAMS_LINE_CODE, lineCode)
            .param(HomeBuyTicketsActivity.PARAMS_LINE_NAME, lineName)
            .param(HomeBuyTicketsActivity.PARAMS_TIME_INDEX, selectedTimeIndex)
            .param(HomeBuyTicketsActivity.PARAMS_START_POS, startStationPos)
            .param(HomeBuyTicketsActivity.PARAMS_END_POS, endStationPos)
            .param(HomeBuyTicketsActivity.PARAMS_STATIONS_LIST, stationsList)
            .param(HomeBuyTicketsActivity.PARAMS_IS_FROM_HOME, isFromHome)
    }


    fun toLineDetails(bean: HomeLineEntity.DataBean): RouteNavigation {
        return RouteNavigation(HOME_LINE_DETAILS).param(HomeLineDetailsActivity.PARAMS_HOME_LINE_DATA, bean)
    }

    /**
     * 跳转至消息通知界面
     */
    fun toNotice(): RouteNavigation {
        return RouteNavigation(NOTICE_LIST)
    }

    /**
     * 跳转至消息通知界面
     */
    fun toNoticeDetail(bean: NoticeEntity.DataBean, isFirst: Boolean = false): RouteNavigation {
        return RouteNavigation(NOTICE_DETAILS).param(NoticeDetailsActivity.PARAMS_DETAILS, bean)
            .param(NoticeDetailsActivity.PARAMS_IS_FIRST_NOTICE, isFirst)
    }
}